import React from 'react';
import loadjs from 'loadjs';
import { workflowPublicFiles } from '../constants/fileConfig';
import { observer } from "mobx-react/index";

@observer
export default class Forward extends React.Component{
    constructor(){
        super();
        this.state = {
            hasLoad: false,
        };
    }
    componentDidMount(){
        const init = () =>{
            const { WfBatchShareStore } = window.weaWorkflowPublic;
            const store = new WfBatchShareStore();
            this.setState({hasLoad: true,store:store});
        };
        loadjs.isDefined('workflowPublic') ? loadjs.ready('workflowPublic', init) : loadjs(workflowPublicFiles, 'workflowPublic', init);
    }
    render(){
        const { hasLoad ,store} = this.state;
        if(hasLoad){
            const { WfBatchShare } = window.weaWorkflowPublic;
            return (<WfBatchShare ecId={`${this && this.props && this.props.ecId || ''}_WfBatchShare@6c9mw5`} {...this.props} wfShareBatchStore={store}/>);
        }else{
            return ( <div></div>);
        }
    }
}